import request from "utils/request";

/**
 * 删除文章
 * @param {*} id
 * @returns
 */
export const delArticle = id => {
  return request({
    url: `v1_0/mp/articles/${id}`,
    method: "delete",
  });
};
/**
 * 发送请求添加文章
 * @param {*} data
 * @returns
 */
export const addArticle = data => {
  return request({
    url: "/v1_0/mp/articles?draft=" + data.draft,
    method: "post",
    data,
  });
};

/**
 * 根据id获取文章详情
 * @param {*} id
 * @returns
 */
export const getArticleApi = id => {
  return request({
    url: `/v1_0/mp/articles/${id}`,
    method: "get",
  });
};

/**
 * 发送请求修改文章
 * @param {*} data
 * @returns
 */
export const editArticle = (data, draft = false) => {
  return request({
    url: `v1_0/mp/articles/${data.id}?draft=${draft}`,
    method: "put",
    data,
  });
};
